package com.yj.timecapsule.config;

import com.yj.timecapsule.websocket.ai.WebSocketCallHandler;
import com.yj.timecapsule.websocket.friendChat.WebSocketChatHandler;
import com.yj.timecapsule.websocket.interceptor.WebSocketInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.*;

/**
 * @author Sean
 * @CreateTime 2024-08-01  14:20
 * @Description
 * @Version 1.0
 */
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
    @Resource
    private WebSocketChatHandler webSocketChatHandler;
    @Resource
    private WebSocketInterceptor webSocketInterceptor;
    @Resource
    private WebSocketCallHandler callHandler;



    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(webSocketChatHandler,"/chat").addHandler(callHandler,"/call").setAllowedOrigins("*").addInterceptors(webSocketInterceptor);

    }
}
